<template>
  <div class="home_page">
    <div class="top">

    </div>
    <div class="main">
      <div class="left"></div>
      <div class="content">
        <RouterView></RouterView>
      </div>
      <div class="right"></div>
    </div>
    <div class="bottom">
      <div class="changePage_btn">
        <RouterLink class="routerLink" v-for="(item, index) in RouterHomeChildren" :key="item.path" :to="item.path"
          @click="changeRouter(index)">
          <img :src="currentRouter === index ? item.changeEd_img : item.beforChange_img" alt="">
        </RouterLink>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { RouterView, RouterLink } from 'vue-router';
import { RouterHomeChildren } from '@/router/index';';'
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute()
const currentRouter = ref(0)

watch(() => route.matched, () => {
  currentRouter.value = Number(route.matched[1].meta.code)
},
  {
    immediate: true
  })

const changeRouter = (index: number) => {
  currentRouter.value = index
}

</script>

<style scoped lang="scss">
.home_page {
  width: 100vw;
  height: 100vh;
  background-image: url("../assets/pageBg.png");
  background-size: 100% 100%;
  position: relative;
  box-sizing: border-box;

  .top {
    width: 100%;
    height: 92px;
    background-image: url("../assets/images/Top.png");
    background-size: 100% 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
  }

  .main {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;

    .left {
      width: 605px;
      height: 100%;
      background-image: url("../assets/images/Left.png");
      background-size: 100% 100%;
    }

    .content {
      width: 1780px;
      height: 85%;
      position: absolute;
      left: calc(50% - 890px);
      top: 10%;
    }

    .right {
      width: 605px;
      height: 100%;
      background-image: url("../assets/images/Right.png");
      background-size: 100% 100%;
    }
  }

  .bottom {
    width: 1092px;
    height: 127px;
    background-image: url("../assets/images/菜单栏.png");
    background-size: 100% 100%;
    position: absolute;
    left: calc(50% - 546px);
    bottom: 0;
    display: flex;
    justify-content: center;

    .changePage_btn {
      width: 415px;
      height: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .routerLink {
        width: 100px;
        height: 100px;

        img {
          width: 100%;
          height: 100%;
        }
      }
    }

  }
}
</style>